export default {
	data() {
		return {
			name: null,
			idcard: null,
			token: null,
			uid: null,
			isauthentication: 0,
			height: 0,
		}
	},
	methods: {
		goback() {
			uni.navigateBack()
		},
		tijiao() {
			var self = this
			if (self.name == null || self.name == "") {
				uni.showToast({
					title: "请输入昵称",
					icon: 'none',
				});
				return
			}
			http.post("/hall/set_userinfo", {
				nickname: self.name
			}).then((res) => {
				if (res.code && res.code != 200) {
					uni.showToast({
						title: res.description,
						icon: 'none',
					});
					return
				}
				uni.$emit('changeuserinfo', {
					nickname: self.name
				});
				uni.showToast({
					title: "设置成功!",
					icon: 'none',
				});
			}).catch((err) => {
				uni.showToast({
					title: "设置失败!",
					icon: 'none',
				});
				console.error(err)
			})
		},
		getuserinfo() {
			var self = this
			http.get("/hall/get_userinfo").then((res) => {
				console.log(res)
				if (res.code && res.code != 200) {
					uni.showToast({
						title: res.description,
						icon: 'none',
					});
					return
				}
				self.name = res.data.user.nickname
			}).catch((err) => {
				uni.showToast({
					title: "获取用户信息失败，请稍后重试!",
					icon: 'none',
				});
			})
		}
	},
	onLoad: function(option) {
		var self = this
		uni.getSystemInfo({
			//成功获取的回调函数，返回值为系统信息
			success: (sysinfo) => {
				self.height = sysinfo.statusBarHeight + 'px'
			},
			complete: () => {}
		});
		uni.getStorage({
			key: 'uni_id_token',
			success: function(res) {
				console.log(res.data);
				self.token = res.data
			}
		});
		uni.getStorage({
			key: 'uid',
			success: function(res) {
				console.log(res.data);
				self.uid = res.data
				self.getuserinfo()
			}
		});
	},
}